package com.bluemoon.daps.test.sync.v1_3.devimport.v1;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author Jarod.Kong
 * @date 2021/6/2 13:19
 */
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "导入开发库对比列表")
public class DevModelCompareVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("表名")
    private String tableName;

    @ApiModelProperty(value = "类型：字段、表、索引", hidden = true)
    private Type type;

    @ApiModelProperty("类型：字段、表、索引")
    private String typeStr;

    @ApiModelProperty("开发库字段/索引")
    private String devProp;

    @ApiModelProperty("模型设计字段/索引")
    private String modelProp;

    @ApiModelProperty(value = "导入结果：新增、删除、修改", hidden = true)
    private Action action;

    @ApiModelProperty("导入结果：新增、删除、修改")
    private String actionStr;

    public String getTypeStr() {
        return getType() != null ? getType().getDesc() : null;
    }

    public String getActionStr() {
        return getAction() != null ? getAction().getDesc() : null;
    }

    public enum Action {
        Create("新增", 0),
        Delete("删除", 1),
        Update("修改", 2),
        Ignore("忽略", 3);

        private final String desc;
        private final int code;

        Action(String desc, int code) {
            this.desc = desc;
            this.code = code;
        }

        public String getDesc() {
            return desc;
        }

        public int getCode() {
            return code;
        }
    }

    public enum Type {
        Table("表", 0),
        Field("字段", 1),
        Index("索引", 2);

        private final String desc;
        private final int code;

        Type(String desc, int code) {
            this.code = code;
            this.desc = desc;
        }

        public String getDesc() {
            return desc;
        }

        public int getCode() {
            return code;
        }
    }


}
